<?php
/* SVN FILE: $Id$ */
/**
 * Short description for file.
 *
 * This file is application-wide controller file. You can put all
 * application-wide controller-related methods here.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.cake.libs.controller
 * @since         CakePHP(tm) v 0.2.9
 * @version       $Revision$
 * @modifiedby    $LastChangedBy$
 * @lastmodified  $Date$
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
/**
 * This is a placeholder class.
 * Create the same file in app/app_controller.php
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package       cake
 * @subpackage    cake.cake.libs.controller
 */
class AppController extends Controller {
	
	var $components = array('Acl', 'Auth','Menu');
	
	var $helpers = array('Menu','Form');
	
	protected $current_user;

    function beforeFilter() {
        //Configure AuthComponent
        $this->Auth->authorize = 'actions';
        $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'redirectuser');
        $this->Auth->actionPath = 'controllers/';        
        
        //$this->Auth->allowedActions = array('*');
        
        if(!$this->Session->check('Auth.User')) {
        	$this->current_user = null;
        }else{
        	
        	$user = $this->Session->read('Auth.User');
        	
        	$groupModel = ClassRegistry::init('Group');
        					
			$params = array('conditions'=>array("Group.id"=>$user['group_id']));
			$group = $groupModel->find('first',$params);	
			
			$this->current_user['User'] = $user;
			$this->current_user['Group'] = $group;
        }
    }
    
    /**
	function beforeFilter() {
    	parent::beforeFilter(); 
    	$this->Auth->allowedActions = array('*');
	}
	**/
	
}
?>